package com.my.lock.v4;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class PrimitiveOperation {

    public static void main(String[] args) throws Exception {
        AtomicInteger count = new AtomicInteger(0);

        List<Thread> threads = new ArrayList<>();
        for (int i = 0; i < 3000; i++) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    count.incrementAndGet();
                    count.incrementAndGet();
                    count.incrementAndGet();
                }
            });
            threads.add(thread);
            thread.start();
        }

        for (Thread thread : threads) {
            thread.join();
        }

        System.out.println(count.get());
    }
}
